The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
Cache-FastMmap-CImpl/CImpl.pm 22
Cache-FastMmap-CImpl/mmap_cache.c 412
Changes 06
FastMmap.pm 22
MANIFEST 01
META.yml 11
README 11
t/16.t 042
t/FastMmapTest.pl 00
9 files changed (This is a version diff) 1067
@@ -15,7 +15,7 @@ use 5.006;
 use strict;
 use warnings;
 
-our $VERSION = '1.34';
+our $VERSION = '1.35';
 
 require XSLoader;
 XSLoader::load('Cache::FastMmap::CImpl', $VERSION);
@@ -38,7 +38,7 @@ Rob Mueller E<lt>cpan@robm.fastmail.fmE<gt>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright (C) 2003 by FastMail IP Partners
+Copyright (C) 2003-2010 by The FastMail Partnership
 
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself. 
@@ -986,6 +986,7 @@ MU32 * _mmc_find_slot(
   MU32 slots_left, * slots_end;
   /* Modulo hash_slot to find starting slot */
   MU32 * slot_ptr = cache->p_base_slots + (hash_slot % cache->p_num_slots);
+  MU32 * first_deleted = (MU32 *)0;
 
   /* Total slots and pointer to end of slot data to do wrapping */
   slots_left = cache->p_num_slots;
@@ -1003,12 +1004,16 @@ MU32 * _mmc_find_slot(
 
     /* data_offset == 0 means empty slot, and no more beyond */
     /* data_offset == 1 means deleted slot, we can reuse if writing */
-    if (data_offset == 0 || (data_offset == 1 && mode == 1)) {
-
+    if (data_offset == 0) {
       /* Return pointer to last checked slot */
       return slot_ptr;
     }
-
+    if (data_offset == 1 && mode == 1 && 0 == slot_ptr) {
+      /* Save pointer to first usable slot; if we don't find the key later,
+         we'll fall back to returning this.
+      */
+      first_deleted = slot_ptr;
+    }
     /* deleted slot, keep looking */
     if (data_offset == 1) {
 
@@ -1032,7 +1037,10 @@ MU32 * _mmc_find_slot(
     ASSERT(slot_ptr >= cache->p_base_slots && slot_ptr < slots_end);
   }
 
-  return 0;
+  if (1 == mode && 0 != first_deleted)
+    return first_deleted;
+  else
+    return 0;
 }
 
 /*
@@ -1,5 +1,10 @@
 Revision history for Perl extension Cache::FastMmap.
 
+1.35 Fri Feb 19 12:45 2010
+  - Fix for returning potential bug that returns old stored
+     data. Could occur if you mix deletes
+     (thanks Darrell Bishop)
+
 1.34 Fri Jun 19 12:00 2009
   - perldoc fix (thanks Jonathan Yu)
 
@@ -17,6 +22,7 @@ Revision history for Perl extension Cache::FastMmap.
     cache is left at interpreter exit time (required
     Scalar::Util qw(weaken) for object tracking)
 
+>>>>>>> .r21903
 1.30 Fri May 8  11:10 2009
   - Fix for Mandriva compiler (thanks Jean-Christian Hassler)
 
@@ -287,7 +287,7 @@ use strict;
 use warnings;
 use bytes;
 
-our $VERSION = '1.34';
+our $VERSION = '1.35';
 
 # Track currently live caches so we can cleanup in END {}
 #  if we have empty_on_exit set
@@ -1271,7 +1271,7 @@ Rob Mueller L<mailto:cpan@robm.fastmail.fm>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright (C) 2003-2008 by FastMail IP Partners
+Copyright (C) 2003-2010 by The FastMail Partnership
 
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself. 
@@ -23,6 +23,7 @@ t/12.t
 t/13.t
 t/14.t
 t/15.t
+t/16.t
 t/2.t
 t/3.t
 t/4.t
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:                Cache-FastMmap
-version:             1.34
+version:             1.35
 abstract:            Uses an mmap'ed file to act as a shared memory interprocess cache
 license:             ~
 author:              
@@ -25,7 +25,7 @@ Rob Mueller <cpan@robm.fastmail.fm>
 
 COPYRIGHT AND LICENCE
 
-Copyright (C) 2003-2009 by FastMail IP Partners
+Copyright (C) 2003-2010 by The FastMail Partnership
 
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself. 
@@ -0,0 +1,42 @@
+
+#########################
+
+use Test::More tests => 3;
+BEGIN { use_ok('Cache::FastMmap') };
+use strict;
+
+#########################
+
+# Insert your test code below, the Test::More module is use()ed here so read
+# its man page ( perldoc Test::More ) for help writing this test script.
+
+my $FC = Cache::FastMmap->new(
+  init_file => 1,
+  raw_values => 0,
+  num_pages => 1,
+  page_size => 2 ** 15,
+);
+ok( defined $FC );
+
+my @d;
+
+for (1 .. 20) {
+
+  $FC->set($_, $d[$_]=$_) for 1 .. 100;
+
+  for (1 .. 50) {
+    $FC->remove($_*2);
+    $d[$_*2] = undef;
+
+    $FC->set($_, $_*2);
+    $d[$_] = $_*2;
+
+    for my $c (1 .. 100) {
+      my $v = $FC->get($c);
+      ($v || 0) == ($d[$c] || 0)
+        || die "at offset $c, got $v expected $d[$c]";
+    }
+  }
+
+}
+ok(1, "ordering santity tests complete");
diff --git a/var/tmp/source/ROBM/Cache-FastMmap-1.34/Cache-FastMmap-1.34/t/FastMmapTest.pl b/var/tmp/source/ROBM/Cache-FastMmap-1.35/Cache-FastMmap-1.35/t/FastMmapTest.pl
old mode 100644
new mode 100755